package Operation;

import Dao.DataOperation;
import JavaBeans.Book;

import java.util.Scanner;

/**
 * 查找图书功能
 */
public class SearchOperation implements IOperation{

    @Override
    public void operate() {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入您要查询的图书ID：");
        int id = in.nextInt();
        in.nextLine(); //过滤多余的换行符
        String sql = "select * from book_list where id = ?";
        Book book = DataOperation.queryOne(Book.class, sql, id);
        if(book != null){
            System.out.println(book);
        }else{
            System.out.println("没有您要查询的图书记录。");
        }
    }
}
